package com.file.system.entity.system;


import com.file.system.entity.basic.WebBasic;
import com.file.system.plugin.dict.Dict;
import com.file.system.plugin.validated.SQLInjectionValidation;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;
import javax.validation.groups.Default;
import java.io.Serializable;


/**
 * 部门
 *
 * @author jch
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class WebDepartment extends WebBasic implements Serializable {

    private static final long serialVersionUID = 1L;


    //新增
    public interface add extends Default {
    }


    //修改
    public interface update extends Default {
    }

    /**
     * 主键
     *
     * @mock
     */
    @NotNull(groups = {update.class}, message = "主键不能为空")
    @Min(value = 1, message = "id长度最小1")
    private Long id;
    /**
     * 父级部门id
     *
     * @mock
     */
    @Min(value = 1, message = "父级部门id最小1")
    private Long pid;
    /**
     * 行政区划编码（字典）
     *
     * @mock
     */
    @NotNull(groups = {add.class, update.class}, message = "行政区划编码不能为空")
    @Size(min = 1, max = 20, message = "行政区划编码长度1-100")
    @Dict("area")
    @SQLInjectionValidation(fieldName = "行政区划编码")
    private String dictArea;
    /**
     * 启用禁用（字典）
     *
     * @mock
     */
    @NotNull(groups = {add.class, update.class}, message = "启用禁用不能为空")
    @Size(min = 1, max = 1, message = "启用禁用长度1")
    @Dict("onOff")
    @SQLInjectionValidation(fieldName = "启用禁用")
    private String dictOnOff;
    /**
     * 名称
     *
     * @mock
     */
    @NotEmpty(groups = {update.class, add.class}, message = "名称不能为空")
    @Size(min = 1, max = 100, message = "名称长度1-100")
    @SQLInjectionValidation(fieldName = "名称")
    private String name;
    /**
     * 排序
     *
     * @mock
     */
    @NotNull(groups = {add.class, update.class}, message = "排序不能为空")
    @Min(value = 1, message = "排序人最小1")
    @Max(value = 2000, message = "排序最大2000")
    private Integer sort;
    /**
     * 部门类型
     *
     * @mock
     */
    @NotEmpty(groups = {update.class, add.class}, message = "部门类型不能为空")
    @Size(min = 1, max = 20, message = "部门类型长度1-20")
    @Dict("departmentType")
    @SQLInjectionValidation(fieldName = "部门类型")
    private String dictType;
    /**
     * 是否为文件夹
     */
    private boolean isLeaf = false;
}
